<template>
  <div class="edit_exam_warpper">
    <a-button @click.stop="handleEdit"> 编辑 </a-button>

    <a-button @click.stop="handleCopy"> 复制 </a-button>

    <a-button @click.stop="handleDelete"> 删除 </a-button>

    <a-button @click.stop="handleMoveUp"> 上移 </a-button>

    <a-button @click.stop="handleMoveDown"> 下移 </a-button>

    <a-button @click.stop="handleMoveTop"> 最上 </a-button>

    <a-button @click.stop="handleMoveBottom"> 最下 </a-button>
  </div>
</template>
<script lang="ts">
import { useDesignContentStore } from '@/store/design';
import { ExamItem } from '@/store/design/types';
import { defineComponent } from 'vue';
import ExamStatus from '../types/exam-status';
export default defineComponent({
  components: {},
  props: {
    questNum: { type: Number, default: 0 },
    exam: { type: ExamItem, required: true },
  },
  setup(props) {
    const contentStore = useDesignContentStore();
    const handleEdit = () => {
      if (props.exam.status === 'basic') {
        props.exam.status = ExamStatus.Edit;
      } else {
        props.exam.status = ExamStatus.Basic;
      }
    };

    const handleCopy = () => {
      contentStore.copyExam(props.exam);
    };

    const handleDelete = () => {
      contentStore.deleteExam(props.exam);
    };

    const handleMoveUp = () => {
      contentStore.moveUpExam(props.exam);
    };

    const handleMoveDown = () => {
      contentStore.moveDownExam(props.exam);
    };
    const handleMoveTop = () => {
      contentStore.moveTopExam(props.exam);
    };

    const handleMoveBottom = () => {
      contentStore.moveBottomExam(props.exam);
    };
    return {
      handleEdit,
      handleCopy,
      handleDelete,
      handleMoveUp,
      handleMoveDown,
      handleMoveTop,
      handleMoveBottom,
    };
  },
});
</script>
<style lang="less" scoped>
.edit_exam_warpper {
  button {
    border: 1px solid #b1b1b1;
    text-align: center;
    margin: 0px 3px;
    border-radius: 2px;
    background: #fff;
    width: 56px;
    height: 25px;
  }
  :global(.ant-btn) {
    padding: 0;
  }
}
</style>
